package cn.iocoder.yudao.module.data.dal.mysql.dstable;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.data.dal.dataobject.dstable.DsTableDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.data.controller.admin.dstable.vo.*;

/**
 * table数据集 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface DsTableMapper extends BaseMapperX<DsTableDO> {

    default PageResult<DsTableDO> selectPage(DsTablePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DsTableDO>()
                .likeIfPresent(DsTableDO::getName, reqVO.getName())
                .likeIfPresent(DsTableDO::getTableName, reqVO.getTableName())
                .eqIfPresent(DsTableDO::getDescription, reqVO.getDescription())
                .eqIfPresent(DsTableDO::getDatasourceId, reqVO.getDatasourceId())
                .eqIfPresent(DsTableDO::getDatasetGroupId, reqVO.getDatasetGroupId())
                .eqIfPresent(DsTableDO::getType, reqVO.getType())
                .eqIfPresent(DsTableDO::getInfo, reqVO.getInfo())
                .eqIfPresent(DsTableDO::getSqlVariableDetails, reqVO.getSqlVariableDetails())
                .orderByDesc(DsTableDO::getId));
    }

}